package com.kolon.business.app.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.kolon.business.app.dao.AppDao;
import com.kolon.framework.interfaces.SimpleController;
import com.kolon.framework.util.ComUtil;

/**
 * 클라이언트 앱 (KolonApp) 최신버전을 보내주는 클래스
 * @author stone
 */
@Controller("com.kolon.business.auth.controller.AppVerController")
public class AppVerController implements SimpleController {

	@Resource(name="AppDaoImpl")
	private AppDao appDao;
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@RequestMapping(value="/business/app/appVer.do")
	public ModelAndView controller(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		Map map = new HashMap();
		ModelAndView modelAndView = new ModelAndView();
		map.put("frfTp", ComUtil.getMobileOS(request.getHeader("user-agent")));
		// 서비스 조회
		Map appInfo = appDao.getMap(map);
		// 서비스 존재여부 체크
		if (appInfo == null || appInfo.isEmpty())
			modelAndView.addObject("appVer", "NOT");
		else
			modelAndView.addObject("appVer", appDao.getMap(map).get("FRF_VER"));	
		return modelAndView;
	}

}
